{% extends 'base.html' %}

{% block title %}文件下载{% endblock %}



{% block content %}
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            {% block main %}
                <h2>文件下载
                {% if salt_server %}
                    <small style="color: red" class="text-danger">{{ salt_server.idc }} -- {{ salt_server.url }} -- {{ salt_server.role }}</small>
                {% endif %}
                {% if not salt_server %}
                    <small style="color: red" class="text-danger">请先添加SaltServer API</small>
                {% endif %}
                    <div class="btn-group pull-right">
                        <a class="btn btn-info" href="/admin/saltstack/saltserver/add/" target="_blank" title="添加Saltmaster"><span class="glyphicon glyphicon-plus"></span> 添加API</a>

                {#        <a class="btn btn-info" href="/admin/saltstack/svnproject/add/" target="_blank" title="新建项目"><span class="glyphicon glyphicon-plus"></span>新建项目</a>#}
                {#            Server选择#}
                        <div class="btn-group pull-right dropdown">
                            <a href="#" class="btn btn-info dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                &nbsp;SaltServer&nbsp;<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                {% for s in server_list %}
                                    <li><a href="/deploy/downloadFile/{{s.id}}/">{{ s.idc }} -- {{ s.url }}</a></li>
                                {% endfor %}
                            </ul>
                        </div>
                    </div>
                </h2>
                {% if error %}
                    <div class="alert alert-danger">
                        <a href="#" class="close" data-dismiss="alert">&times;</a>
                        {{ error }}
                    </div>
                {% endif %}
                {% if success %}
                    <div class="alert alert-success">
                        <a href="#" class="close" data-dismiss="alert">&times;</a>
                            {{ success }}
                    </div>
                {% endif %}

                <form enctype="multipart/form-data" action="/deploy/downloadFile/{{server_id}}/" method="post">
                    <li class="nav">目标主机：<input type="text" name="server" value="{{ server }}" /> <small style="color: red">多个目标主机以英文逗号(,)分隔</small></li>
                    <br/>
                    <li class="nav">目标路径：<input type="text" name="dest" value="{{ dest }}" /> </li>
                   <br/>
                   <input type="submit" value="浏览"/>
                </form>

                {% if code %}
                    <meta http-equiv="refresh" content="0; url={{ nginx_url }}{{ files }}" />
                {% endif %}

                {% if files_list %}
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>文件名</th>
                                <th>管理</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for file in files_list %}
                            <tr class="gradeA">
                                <td >{{ file }} </td>
                                <td>
                                    <form enctype="multipart/form-data" action="/deploy/download/{{server_id}}/" method="post">
                                        <a href="javascript:;" class="file">
                                            <input name="server" type="text" value="{{ server }}">
                                            <input name="dest" type="text" value="{{ dest }}">
                                            <input name="myfile" type="text"  value="{{ file }}" />下载
                                            <input type="submit"/>
                                        </a>
                                    </form>
                                </td>
                             </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                {% endif %}
            {% endblock %}
        </div>
    </div>
</div>
{% endblock %}

